<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
// for(初始化表达式;条件;迭代因子){
//     语句
// }

        //从1打印到100
        var i;
        var sum = 0;
        for(i=1;i<=100;i++){

            console.log(i); 
            sum+=i;
        }
        console.log(sum);//输出从1加到100的结果
        
    </script>
</body>
</html>